import i18n, { pageNotBuildByUserInfo } from '@src/locales'

import { getAllGrayInfo } from '@src/util/grayInfo'
import { checkIp } from '@src/api/Address';
import { GrayFunctionEnum } from 'pub-bbx-global/pageType/dist/grayFunction'
import { bbxForMapUtils } from 'pub-bbx-utils'

(window as any).initMap = function() {
  console.log('initMap ()=> 地图加载成功')
}


export const useMapType = async ()=>{
  // 分享页面不需要初始化
  const url_ = window.location.href;
  const isSharePage = pageNotBuildByUserInfo.find(item => url_.includes(item))
  let internationalGray = {}
  let isDomestic = false
  if(!isSharePage){
    internationalGray = await getAllGrayInfo()
    isDomestic = await checkIp()
  }
  const gray = !!internationalGray[GrayFunctionEnum.INTERNATIONAL]
  return bbxForMapUtils(i18n.locale, gray, isDomestic)
}